/**
 *	\file AKContainer.m
 *  
 *  \section desc_sec Description
 *  Description
 *  
 *  \if copyright
 *  	Copyright 2008 Ben Chen. All rights reserved.
 *  \endif
 *  
 *  \section hist_sec Change History:
 *  	-	1/19/08		BC		Created this file
 *  
 *  <hr>
 *  \addtogroup AnimalKingdom
 *  @{
 */

#import "AKContainer.h"

#import "AKTTT.h"
#import "AKTTTAIPlayer.h"
#import "AKTTTBasicInfoProvider.h"
#import "AKTTTGeometryProvider.h"
#import "AKTTTStateMaintainer.h"
#import "AKTTTImageProvider.h"

#import "AKBasicDrawing.h"
#import "AKInteractiveDrawing.h"

#import "AKDrawing.h"
#import "AKMediator.h"

#import "AKHumanPlayer.h"

@implementation AKContainer

- (void)awakeFromNib
{
	Class playerAClass			= [AKTTTAIPlayer class];
	Class playerBClass			= [AKHumanPlayer class];
	Class basicInfoClass		= [AKTTTBasicInfoProvider class];
	Class geometryClass			= [AKTTTGeometryProvider class];
	Class stateMaintainerClass	= [AKTTTStateMaintainer class];
	Class imageProviderClass	= [AKTTTImageProvider class];
	
	id <AKPlayer> playerA = [[playerAClass alloc] init];
	playerA.side = 0;
	id <AKPlayer> playerB = [[playerBClass alloc] init];
	playerB.side = 1;
		
	id <AKBasicInfoProvider>  basicInfo		= [[basicInfoClass alloc] init];
	id <AKGeometryProvider>	  geometry		= [[geometryClass alloc] init];
	id <AKStateMaintainer>	stateMaintainer	= [[stateMaintainerClass alloc] init];
	id <AKImageProvider> imageProvider		= [[imageProviderClass alloc] init];
	
	AKDrawing *drawing = [[AKDrawing alloc] initWithImageProvider:imageProvider
												 geometryProvider:geometry
												basicInfoProvider:basicInfo
												 // stateMaintainer:stateMaintainer
														 drawView:drawingView];
	
	((AKHumanPlayer*)playerB).interactiveDrawing	= drawing;
	((AKHumanPlayer*)playerB).stateMaintainer		= stateMaintainer;

	// [drawingView setDelegate:drawing];
	
	AKMediator *mediator = [[AKMediator alloc] initWithBasicInfoProvider:basicInfo
														geometryProvider:geometry
														 stateMaintainer:stateMaintainer
																 players:[NSArray arrayWithObjects:playerA, playerB, nil]
														   imageProvider:imageProvider
															 basicObject:drawing 
																drawView:drawingView];
	
	[(id)basicInfo			release];
	[(id)geometry			release];
	[(id)stateMaintainer	release];
	[(id)imageProvider		release];
	
	NSSize boardSize = [geometry chessboardSize];
	/*
	[mainWindow setFrame:NSMakeRect(0, 0, boardSize.width, boardSize.height)
				 display:YES];
	 */
	[mainWindow setContentAspectRatio:boardSize];
	[mainWindow center];
	
	[mediator start];	
}

@end

/** @} */
